package com.lindroy.jetpacknotes.navigation.args.fragment

import android.os.Bundle
import com.lindroy.jetpacknotes.R
import com.lindroy.jetpacknotes.base.BaseFragment
import com.lindroy.jetpacknotes.constants.KEY_AGE
import com.lindroy.jetpacknotes.constants.KEY_NAME
import kotlinx.android.synthetic.main.fragment_receiver.*

class ReceiverFragment : BaseFragment(R.layout.fragment_receiver) {

    private val name by lazy { arguments?.getString(KEY_NAME) ?: "" }

    private val age by lazy { arguments?.getInt(KEY_AGE) ?: -1 }

    override fun initView(savedInstanceState: Bundle?) {
        if (name.isNotEmpty() && age > 0) {
            tvData.text = "名字：$name，年龄：$age"
        } else {
            arguments?.also {
                val args = SenderFragmentArgs.fromBundle(it)
                tvData.text = "名字：${args.name}，年龄：${args.age}"
            }
        }
    }

    override fun initListener() {
    }
}